/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "ITEM_CATALOG")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ItemCatalog.findAll", query = "SELECT i FROM ItemCatalog i"),
    @NamedQuery(name = "ItemCatalog.findByIdItemCatalog", query = "SELECT i FROM ItemCatalog i WHERE i.itemCatalogPK.idItemCatalog = :idItemCatalog"),
    @NamedQuery(name = "ItemCatalog.findByIdCatalog", query = "SELECT i FROM ItemCatalog i WHERE i.itemCatalogPK.idCatalog = :idCatalog")})
public class ItemCatalog implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ItemCatalogPK itemCatalogPK;
    @JoinColumns({
        @JoinColumn(name = "ID_PRODUCT", referencedColumnName = "ID_PRODUCT"),
        @JoinColumn(name = "ID_BRANCHENTERPRISE1", referencedColumnName = "ID_BRANCHENTERPRISE"),
        @JoinColumn(name = "ID_ENTERPRISE1", referencedColumnName = "ID_ENTERPRISE"),
        @JoinColumn(name = "ID_ITEM", referencedColumnName = "ID_ITEM")})
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private Item item;
    @JoinColumn(name = "ID_CATALOG", referencedColumnName = "ID_CATALOG", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Catalog catalog;

    public ItemCatalog() {
    }

    public ItemCatalog(ItemCatalogPK itemCatalogPK) {
        this.itemCatalogPK = itemCatalogPK;
    }

    public ItemCatalog(BigInteger idItemCatalog, BigInteger idCatalog) {
        this.itemCatalogPK = new ItemCatalogPK(idItemCatalog, idCatalog);
    }

    public ItemCatalogPK getItemCatalogPK() {
        return itemCatalogPK;
    }

    public void setItemCatalogPK(ItemCatalogPK itemCatalogPK) {
        this.itemCatalogPK = itemCatalogPK;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    public Catalog getCatalog() {
        return catalog;
    }

    public void setCatalog(Catalog catalog) {
        this.catalog = catalog;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemCatalogPK != null ? itemCatalogPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemCatalog)) {
            return false;
        }
        ItemCatalog other = (ItemCatalog) object;
        if ((this.itemCatalogPK == null && other.itemCatalogPK != null) || (this.itemCatalogPK != null && !this.itemCatalogPK.equals(other.itemCatalogPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.ItemCatalog[ itemCatalogPK=" + itemCatalogPK + " ]";
    }
    
}
